﻿Public Class frmOptions

    Private Sub btnBrowse_Click(sender As System.Object, e As System.EventArgs) Handles btnAnimation.Click
        With New OpenFileDialog
            .Filter = "GIS Files (*.gis)|*.gis"
            .Multiselect = False
            If .ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
                grpFiles.Controls(0).Controls(CType(sender, Button).Name.Replace("btn", "txt")).Text = .FileName
            End If
        End With
    End Sub

    Private Sub lnkReset_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkReset.LinkClicked
        frmInfoMsg.ResetAllInfoMsgs()
    End Sub

    Private Sub btnLayer_Click(sender As System.Object, e As System.EventArgs) Handles btnLayer.Click
        With New FolderBrowserDialog
            .SelectedPath = txtLayer.Text
            If .ShowDialog(Me) Then
                txtLayer.Text = .SelectedPath
            End If
        End With
    End Sub

    Private Sub btnCache_Click(sender As System.Object, e As System.EventArgs) Handles btnCache.Click
        With New FolderBrowserDialog
            .SelectedPath = txtCache.Text
            If .ShowDialog(Me) Then
                txtCache.Text = .SelectedPath
            End If
        End With
    End Sub

    Private Sub lnkClearCache_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lnkClearCache.LinkClicked
        Dim oldBasemap As String = "None"
        If GISForm.WebMap IsNot Nothing Then oldBasemap = GISForm.WebMap.ServiceProviderName
        GISForm.SetBasemap("None")
        My.Computer.FileSystem.DeleteDirectory(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TileCache"), FileIO.DeleteDirectoryOption.DeleteAllContents)
        GISForm.SetBasemap(oldBasemap)
    End Sub
End Class